const fs = require('fs');
//解构赋值
const {resolve} = require('path');// {resolve: function(){}}

//声明一个变量保存文件夹的绝对路径
let dir = resolve(__dirname, 'files');// D:/www/atguigu/练习/files

//读取目标文件夹中的文件列表
const files = fs.readdirSync(dir);

console.log(files);

//遍历
// files.forEach((item, index) => {
//   //直接改名 resolve(dir, item)  => D:/www/atguigu/练习/files/01.html
//   fs.renameSync(resolve(dir, item), resolve(dir, `${String(index+1).padStart(2, "0")}.html`));
// });